﻿namespace XNAGameEngine.DataStructures
{
    /// <summary>
    /// The state object used in the FSM class. All states managed in the FSM class must inherit this class.
    /// Additionally, the type inheriting this class must be passed as the second template parameter.
    /// </summary>
    /// <typeparam name="managerInterfaceType">This parameter must be an interface to the FSM managing this state. It my either be the type of the class inheriting the FSM or an interface to that class. Additionally, you may choose to pass the FSM class itself (FSM<managerType, stateType, managerInterfaceType>)</typeparam>
    /// <typeparam name="stateType">The type which inherits this class.</typeparam>
    public abstract class FSMState<managerInterfaceType, stateType>
    {
        /// <summary>
        /// Reference back to the state manager, this gets set whenever the state is pushed onto the stack
        /// </summary>
        protected internal managerInterfaceType _stateManager;
        
        /// <summary>
        /// Gets the state manager which manages this state
        /// </summary>
        protected managerInterfaceType StateManager
        {
            get { return (managerInterfaceType)_stateManager; }
        }

        /// <summary>
        /// Sets the state manager. This is handled automatically by the FSM class
        /// </summary>
        internal object SetStateManager
        {
            set { _stateManager = (managerInterfaceType)value; }
        }

        /// <summary>
        /// Pause the state before removing it from the stack.
        /// </summary>
        protected internal virtual void Pause() { }

        /// <summary>
        /// Resume the state once it is put on the stack, or the state above it is removed
        /// </summary>
        protected internal virtual void Resume() {}

    }
}
